import pygame,mod_widgets

size = (1200,825)
screen = pygame.display.set_mode(size)


widgetRectMap = {}

buttonGraphic = pygame.image.load('gfx/buttons/handbutton.png').convert()

class TestCommand:
    def doIt(self):
        print 'Test command done!'

button = mod_widgets.Button(buttonGraphic, TestCommand())

uglyGuyGraphic = pygame.image.load('gfx/misc/uglyguy.png').convert()

image = mod_widgets.Image(uglyGuyGraphic)

scrollPane = mod_widgets.ScrollPane((64,64),image,20)

mainPanel = mod_widgets.StackPanel(1200)
#mainPanel.widgets.append(button)
mainPanel.widgets.append(scrollPane)


clock = pygame.time.Clock()

running = True
while running:
    screen.fill( (0,0,128))
    milliseconds = clock.tick(25) # maximum number of frames per second
        
    events = pygame.event.get( )
        
    # Now the main event-processing loop
    if events:
        for event in events:
            if event.type == pygame.QUIT:
                running = False
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    running = False
                elif event.key == pygame.K_DOWN:
                    scrollPane.scroll((0,1))
                elif event.key == pygame.K_UP:
                    scrollPane.scroll((0,-1))
                elif event.key == pygame.K_LEFT:
                    scrollPane.scroll((-1,0))
                elif event.key == pygame.K_RIGHT:
                    scrollPane.scroll((1,0))
            elif event.type == pygame.MOUSEBUTTONDOWN:
                mainPanel.handleClick(event.pos,event.button)
    screen.blit(mainPanel.update(),(0,0))
    pygame.display.update()
    